package com.gmail.liulijuan.class3;

import com.gmail.liulijuan.class2.Sorter;

public class MyApp2 {

	/**
	 * @param args
	 */
	/**public static void main(String[] args) {
		int t=0;
		int[] a=new int[100];
		int[] b,c,d;
		for (int i = 0; i < a.length; i++) {
			a[i]=i;
		}
		Sorter aa= new Sorter();
		aa.setC(a);
		
	//}
		
		
		
		
		//MyApp2 bb= new MyApp2();
		//bb.printArray(a);
		b=aa.sortMaoPao(t);
		System.out.println("This is MaoPaoOrder.");
		bb.printArray(b);
		bb.printArray(a);
		c=aa.sortChaRu(t);
		System.out.println("This is ChaRuOrder.");
		bb.printArray(c);
		bb.printArray(a);
		d=aa.sortShunXu(t);
		System.out.println("This is ShunXuOrder.");
		bb.printArray(d);
	
	
	public static void printArray(int[]a){
		for (int i = 0; i < a.length; i++) {
			System.out.printf("%4d",a[i]);
		}
		System.out.println(" ");
		return;
	}
	
	public class Sorter {
		
		int[] c;
		
		public void setC(int[] a){
			c=new int[a.length];
			for (int i = 0; i < c.length; i++) {
				c[i]=a[i];
			}
		}
		
		public int[] sortChaRu(int t){
			int b;
			if (t==0) {
				for (int i = 0; i < c.length; i++) {
					for (int j = 0; j < i; j++) {
						if (c[i]>c[j]) {
							b=c[i];
							c[i]=c[j];
							c[j]=b;
						}
					}
				}
			} else {
				for (int m = 0; m < c.length; m++) {
					for (int n = 0; n < m; n++) {
						if (c[m]<c[n]) {
							b=c[m];
							c[m]=c[n];
							c[n]=b;
						}
					}
				}
			}
			return c;
		}
		
		public int[] sortMaoPao(int t){
			int b;
			for (int i = 1; i < c.length; i++) {
				for (int j = 0; j < c.length-i; j++) {
					if (c[j+1]>c[j]) {
						b=c[j];
						c[j]=c[j+1];
						c[j+1]=b;
					}	
				}
			}
			if(t>0){
				return reverse(c);
			}
			return c;
		}
			
		public int[] sortShunXu(int t){
			int b;
			for (int i = 0; i < c.length; i++) {
				for (int j = i; j < c.length; j++) {
					if (c[i] < c[j]) {
						b = c[i];
						c[i] = c[j];
						c[j] = b;
					}
				}
			}
			if(t>0){
				return reverse(c);
			}
			return c;
		}
		
		private int[] reverse(int[]a){
			int[] b=new int[a.length];
			for (int i = 0; i < b.length; i++) {
				b[i]=a[a.length-i-1];
			}
			return b;
		}

		

	}*/

}


